package com.yulinlin.authorization.util;

import cn.hutool.core.codec.Base64;
import org.springframework.security.core.Authentication;
import org.springframework.security.core.context.SecurityContextHolder;

public class OauthUtil {

    //得道用户id
    public static <E> E getUserId(){
        Authentication authentication =  SecurityContextHolder.getContext().getAuthentication();
        return (E)authentication.getPrincipal();
    }

    public static String authorization(String username,String password){
        return "Basic "+ Base64.encode(username+":"+password);
    }
}
